package gatilhos;

import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.TextureManager;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import android.content.Context;

public class BotaoGatilho extends Gatilho {

	private BitmapTextureAtlas mapaDeTexturas;
	private TiledTextureRegion textura;

	public BotaoGatilho(int x, int y, Context contexto, TextureManager tm){
		this.x = x;
		this.y = y;
		largura = 64;
		altura = 64;
		
		mapaDeTexturas = new BitmapTextureAtlas(128, 64, TextureOptions.BILINEAR);
		textura = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mapaDeTexturas, contexto, "Gatilho.png", 0, 0, 2, 1);
		tm.loadTexture(mapaDeTexturas);
		
		spriteAnimado = new AnimatedSprite(x, y, textura);
		spriteAnimado.animate(200, true);
	}

	@Override
	public void atualiza() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean colidiuComCaoGuia(AnimatedSprite spriteCaoGuia) {
		if(spriteCaoGuia.collidesWith(spriteAnimado)){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void posicionaNaCena(int mapx, int mapy) {
		spriteAnimado.setPosition((int)x-mapx, (int)y-mapy);
	}

}
